<template>
    <div class="zw-header">
        <div class="zw-logo">
            <img :src="logo" alt="" srcset="">
            <div class="sys-name">真唯销售管理系统</div>
        </div>
        <div class="zw-menu">
            <div class="user-name">{{ userRef?.realName || "" }}</div>
            <el-avatar class="user-avatar" :src="userAvatar"></el-avatar>
            <el-button @click="logout" link
                style="color: #fff;margin-right: 24px;height: 24px;line-height: 24px;">退出登录</el-button>
        </div>
    </div>
</template>
<script lang="ts" setup>
import logo from "@/assets/favicon.ico";
import userAvatar from "@/assets/favicon.ico";
import StoreManager from "@/plugins/storage";
import type { UserVO } from "@/server/user/types";
import { ref } from "vue";
import { useRouter } from "vue-router";

const router = useRouter()
const logout = () => {
    StoreManager.clear();
    router.push({ path: "/login" })
}
const userRef = ref<UserVO | null>(StoreManager.get<UserVO>("user"))
</script>
<style lang="scss" scoped>
.zw-header {
    height: 64px;
    width: 100%;
    display: flex;
    background: v.$background-color;
    flex-direction: row;
    justify-content: space-between;

    .zw-logo {
        height: 64px;
        padding-left: 20px;
        display: flex;
        justify-content: center;
        align-items: center;

        img {
            // background-color: #fff;
            border-radius: 50%;
            width: 40px;
            height: 40px;
            border: 1px solid #fff;
            margin-right: 16px;
        }

        .sys-name {
            font-weight: 600;
            font-size: 22px;
            color: #fff;
        }
    }

    .zw-menu {
        display: flex;
        flex-direction: row;
        justify-content: center;
        align-items: center;

        .user-name,
        .user-avatar {
            margin: 0px 12px 0px 4px;
        }

        .user-name {
            color: #fff;
            height: 24px;
            line-height: 24px;
        }

        .user-avatar {
            background-color: #fff;
        }
    }
}
</style>